﻿using Dapper;
using System;
using System.Data.SQLite;
using System.Runtime.CompilerServices;

namespace Trade.Journal
{
    public class ViewModelBase<T> : BindableBase
    {
        public T Model { get; set; }


    }


    public class DbViewModelBase<T> : ViewModelBase<T>
    {
        /// <summary>
        /// UPDATE {tb} SET {field}=@v
        /// </summary>
        protected string Sql { get; set; }

        protected string DbConnectString { get; set; }

        public bool UpdateToDb(object v, [CallerMemberName]string field = "")
        {
            try
            {
                using (var db = new SQLiteConnection(DbConnectString))
                {
                    db.Open();
                    //db.Execute(Sql,)
                }
            }
            catch (Exception er)
            {
                return false;
            }
            return true;
        }
    }
}
